import { convertWord } from "@/util/xc/utils";

export const SOURCE = {
  USER_SALARY_DTOS: "userSalaryDtos", //  基本工资
  ATTEND_DETAIL_DTOS: "attendDetailDtos", // 考勤明细
  SSAF_RULE_ITEM_DTOS: "ssafRuleItemDtos", // 社保公积金明细
  HOLIDAY_TYPE_DTOS: "holidayTypeDtos", // 假期类型集合
  HOLIDAY_TYPE_VALUE_DTOS: "holidayTypeValueDtos", // 假期类型对应值集合
  ATTEND_SCHEDULE_MODEL: "attendScheduleModel" // 考勤排班数据信息
};

// 主表
export const ITEMS = {
  ADVANCE_TAX: ["yyjse", null, null, "已预缴税额"],
  MONTH_PAYROLL_DAY: ["monthPayrollDay", null, null, "月计薪天数"],
  PAYROLL_DAY: ["payrollDay", null, null, "实际计薪天数"],
  PERSONAL_SOCIAL_SECURITY: ["ssTotal", null, null, "个人社保"],
  PERSONAL_SOCIAL_SECURITY_TOTAL: ["ssTotal", null, null, "个人社保合计"],
  PERSONAL_RESERVE_FUND: ["afTotal", null, null, "个人公积金"],
  ACCUMULATED_INCOME_AS_OF: ["ljsrejzsy", "number", null, "累计收入额（截至上月）"],
  ACCUMULATED_SPECIAL_DEDUCTION_AS_OF: ["ljzxkcjzsy", "number", null, "累计专项扣除（截至上月）"],
  ACCUMULATED_ADVANCE_TAX_AS_OF: ["ljyyjsejzsy", "number", null, "累计已预缴税额（截至上月）"],
  ACCUMULATED_INCOME: ["ljsre", null, null, "累计收入额"],
  ACCUMULATED_DEDUCTION_COST: ["ljjcfy", null, null, "累计减除费用"],
  ACCUMULATED_SPECIAL_DEDUCTION: ["ljzxfjkc", null, null, "累计专项附加扣除"],
  ACCUMULATED_TAXABLE_INCOME: ["ljynssde", null, null, "累计应纳税所得额"],
  ACCUMULATED_TAXABLE: ["ljynse", null, null, "累计应纳税额"],
  SHOULD_SALARY: ["yfWages", null, null, "应发工资"],
  SALARY_TAXABLE: ["ysWages", null, null, "应税工资"],
  PERSONAL_INCOME_TAX: ["grTax", null, null, "个人所得税"],
  ACTUAL_SALARY: ["sfWages", null, null, "实发工资"],
  ATTENDANCE_DEDUCTION_TOTAL: ["kqkkhj", null, null, "考勤扣款合计"],
  OVERTIME_PAY_TOTAL: ["jbfhj", null, null, "加班费合计"],
};

// 考勤表
export const ATTS = {
  ATTS_SHOULD_ATTENDANCE_DAY: ["yAttendanceDay", null, null, "应出勤天数"],
  ATTS_ACTUAL_ATTENDANCE_DAY: ["sjAttendanceDay", null, null, "实际出勤天数"],
  ATTS_ATTENDANCE_BONUS: ["", null, null, "全勤奖"],
  ATTS_LATE_DEDUCTIONS: ["cdDeduction", null, null, "迟到扣款"],
  ATTS_EARLY_DEDUCTIONS: ["ztDeduction", null, null, "早退扣款"],
  ATTS_LACK_DEDUCTIONS: ["qkDeduction", null, null, "缺卡扣款"],
  ATTS_NO_DUTY: ["bzzmf", null, null, "不在职免发"],
  ATTS_ABSENTEEISM_DEDUCTIONS: ["kgDeduction", null, null, "旷工扣款"],
  ATTS_LEAVE_DEDUCTIONS: ["qjDeduction", null, null, "请假扣款"],
  ATTS_WORKDAY_OVERTIME_PAY: ["gzrOvertimePay", null, null, "工作日加班费"],
  ATTS_WEEKEND_OVERTIME_PAY: ["zmOvertimePay", null, null, "周末加班费"],
  ATTS_FESTIVALS_OVERTIME_PAY: ["jjrOvertimePay", null, null, "节假日加班费"],
  ATTS_OVERTIME_PAY_TOTAL: ["overtimePayTotal", null, null, "加班费合计"],
};

// 公积金表
export const SSAF = {
  SSAF_PERSONAL_RESERVE_FUND: ["personalAf", null, null, "个人公积金"],
  SSAF_COMPANY_RESERVE_FUND: ["companyAf", null, null, "企业公积金"],
  SSAF_PERSONAL_SOCIAL_FUND_TOTAL: ["personalSsafTotal", null, null, "个人社保公积金合计"],
  SSAF_COMPANY_SOCIAL_FUND_TOTAL: ["companySsafTotal", null, null, "企业社保公积金合计"],
  SSAF_PERSONAL_SOCIAL_SECURITY: ["personalSs", null, null, "个人社保"],
  SSAF_COMPANY_SOCIAL_SECURITY: ["companySs", null, null, "企业社保"],
  // SSAF_SOCIAL_SECURITY_TOTAL: ["ssTotal", null, null, "社保合计"],
  SSAF_PERSONAL_ANNUITY: ["gryl", null, null, "个人养老"],
  SSAF_COMPANY_ANNUITY: ["gsyl", null, null, "企业养老"],
  SSAF_PERSONAL_UNEMPLOYMENT: ["grsy", null, null, "个人失业"],
  SSAF_COMPANY_UNEMPLOYMENT: ["gssy", null, null, "企业失业"],
  SSAF_PERSONAL_MEDICAL: ["gryil", null, null, "个人医疗"],
  SSAF_COMPANY_MEDICAL: ["gsyil", null, null, "企业医疗"],
  SSAF_PERSONAL_INJURY: ["grgs", null, null, "个人工伤"],
  SSAF_COMPANY_INJURY: ["gsgs", null, null, "企业工伤"],
  SSAF_PERSONAL_BEAR: ["grshengy", null, null, "个人生育"],
  SSAF_COMPANY_BEAR: ["gsshengy", null, null, "企业生育"],
};

// 扣除表
export const SAD = {
  SAD_ACCUMULATED_SPECIAL_DEDUCTION_TOTAL: ["ljzxfjkcTotal", null, null, "累计专项附加扣除合计"],
  SAD_ACCUMULATED_EDUCATION: ["ljznjy", null, null, "累计子女教育"],
  SAD_ACCUMULATED_HOUSE: ["ljzfzj", null, null, "累计住房租金"],
  SAD_ACCUMULATED_LOANS: ["ljzfdk", null, null, "累计住房贷款"],
  SAD_ACCUMULATED_CONTINUING: ["ljjxjy", null, null, "累计继续教育"],
  SAD_ACCUMULATED_ELDER: ["ljsylr", null, null, "累计赡养老人"],
  SAD_ACCUMULATED_INFANT: ["ljyyezh", null, null, "累计婴幼儿照护"],
};

export const COMMON = {
  NAME: ["userName", null, null, "姓名"],
  NUMBER: ["number", null, null, "工号"],
  DEPARTMENT_NAME: ["departmentName", null, null, "部门"],
  POSITION: ["position", null, null, "岗位"],
};

// [字段名, 输入框类型, 拼音名, 中文名]
class tablePair {
  constructor() {
    this.specialArr = ["工作日加班费", "周末加班费", "节假日加班费"];
    this.obj = {
      ...COMMON,
      ...ITEMS,
      ...ATTS,
      ...SSAF,
      ...SAD,
    };
    this.setNamePy();
  }
  setNamePy() {
    this.getArr().forEach((key) => {
      const name = this.obj[key][3];
      if (this.specialArr.includes(name)) {
        this.obj[key][2] = convertWord(name.replace("费", ""));
      } else this.obj[key][2] = convertWord(name);
    });
  }
  getArr() {
    return Object.keys(this.obj);
  }
  getObj() {
    return this.obj;
  }

  /** 匹配中文 */
  getNameMatch(name) {
    const k = this.getArr().find((item) => this.obj[item][3] == name) || "";
    let [key, type = "", namePy = ""] = this.obj[k] || "";
    return [key, type, namePy];
  }

  /** 模糊匹配 */
  getDimMatch(type) {
    const key = this.getArr().find((key) => this.obj[key].includes(type));
    if (key) return this.obj[key];
    else return Array(4).fill(type);
  }
}

export const pair = new tablePair();
